﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Sale_Model;
using Sale_DAL;
using Sale_Common;
namespace Sale_Operation
{
    public class SysMenuOp
    {
        /// <summary>
        /// 获取所有菜单信息
        /// </summary>
        /// <returns></returns>
        public List<SysMenu> GetList()
        {
            List<SysMenu> LS = new List<SysMenu>();
            try
            {
                StringBuilder sbSql = new StringBuilder();
                sbSql.Append(" SELECT SMenu_Id,SMenu_Title,SMenu_Page,SMenu_PId,SMenu_Index,State FROM SysMenu WHERE State=1 ORDER BY SMenu_PId,SMenu_Index ASC ");
                DataBase db = new DataBase();
                SqlHelper.FillDataset(db.Connection, CommandType.Text, sbSql.ToString(), db.Data, new string[] { "dtSysMenu" });
                for (int i = 0; i < db.Data.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = db.Data.Tables[0].Rows[i];
                    SysMenu Menu = new SysMenu();
                    Menu.SMenu_Id = ValueHandler.GetIntNumberValue(dr["SMenu_Id"]);
                    Menu.SMenu_Index = ValueHandler.GetIntNumberValue(dr["SMenu_Index"]);
                    Menu.SMenu_Page = ValueHandler.GetStringValue(dr["SMenu_Page"]);
                    Menu.SMenu_PId = ValueHandler.GetIntNumberValue(dr["SMenu_PId"]);
                    Menu.SMenu_Title = ValueHandler.GetStringValue(dr["SMenu_Title"]);
                    Menu.State = ValueHandler.GetIntNumberValue(dr["State"]);
                    LS.Add(Menu);

                }
            }
            catch (Exception ex)
            { }
            return LS;
        }
    }
}
